#cmake file for common_source_cpp
#author:guyadong
#created:2018/04/24
cmake_minimum_required( VERSION 2.6 )
# 将 common_source_cpp复制到依赖代码文件夹
if(NOT DEPENDENT_SOURCE_DIR)
	set(DEPENDENT_SOURCE_DIR "${PROJECT_BINARY_DIR}/dependent_sources" CACHE STRINGS "dependent source folder" FORCE)
endif()
file(GLOB _common_source_files "${CMAKE_CURRENT_LIST_DIR}/*")
file(COPY ${_common_source_files} 
	DESTINATION ${DEPENDENT_SOURCE_DIR} 
	FILES_MATCHING
	PATTERN "*.h"
	PATTERN "*.cpp"
	PATTERN "*.hpp"
	)
message( STATUS "copy files of ${CMAKE_CURRENT_LIST_DIR} to ${DEPENDENT_SOURCE_DIR}" )
if(NOT MSVC)
	file(REMOVE ${DEPENDENT_SOURCE_DIR}/dirent.h)
	message(STATUS "EXCLUDE dirent.h")
endif()
unset(_common_source_files)

add_library(common_source INTERFACE)
target_include_directories(common_source INTERFACE
  $<BUILD_INTERFACE:${DEPENDENT_SOURCE_DIR}>
  $<INSTALL_INTERFACE:include>
)
